package www.openteam.com.presenter.qualityCntrl;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.IQCCheckItem;
import www.openteam.com.bean.IQCDefectdItem;
import www.openteam.com.contract.qualityCntrl.IQC00Contract;
import www.openteam.com.model.qualityCntrl.IQC00Model;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.qualityCntrl.IQC00Fragment;

/**
 * Created by Administrator on 2018/3/1 0001.
 */

public class IQC00Presenter extends BasePresenter<IQC00Fragment> implements
        IQC00Contract.IQC00Presenter{

    @Override
    public void findCheckItem() {
        ((IQC00Model)getiModelMap().get("IQC00Presenter")).findCheckItem(new IQC00Model.CheckItemListener() {
            @Override
            public void success(IQCCheckItem iqcCheckItem) {
                getIView().findCheckItem(iqcCheckItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findDefectdItem(String code) {
        ((IQC00Model)getiModelMap().get("IQC00Presenter")).findDefectsItem(code, new IQC00Model.DefectsItemListener() {
            @Override
            public void success(IQCDefectdItem iqcDefectdItem) {
                getIView().findDefectdItem(iqcDefectdItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new IQC00Model());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("IQC00Presenter", models[0]);
        return hashMap;
    }
}
